<?php
// Module Definition
$module['name'] = 'External Links';
$module['description'] = 'Manage the external links menu.';

switch($action) {
	case 'register':
		break;
	case 'unregister':
		$SQL = 'DROP TABLE IF EXISTS links';
		mysql_query($SQL);
		break;
	case 'enable':
		$SQL = "CREATE TABLE IF NOT EXISTS `links` (
				  `id` int(11) NOT NULL auto_increment,
				  `name` mediumtext NOT NULL,
				  `url` mediumtext NOT NULL,
				  `submitform` int(11) NOT NULL default '0',
				  `usernamefield` varchar(20) default NULL,
				  `passwordfield` varchar(20) default NULL,
				  `personal` int(11) NOT NULL default '0',
				  `domain` int(11) NOT NULL default '0',
				  `reseller` int(11) NOT NULL default '0',
				  `server` int(11) NOT NULL default '0',
				  `extra` mediumtext,
				  PRIMARY KEY  (`id`)
				) ENGINE=MyISAM AUTO_INCREMENT=4";
		mysql_query($SQL);
		$SQL = "INSERT INTO `links` VALUES (1, '{L:phpMyAdmin}', '/phpMyAdmin/index.php', 1, 'pma_username', 'pma_password', 1, 1, 1, 1, NULL)";
		mysql_query($SQL);
		$SQL = "INSERT INTO `links` VALUES (2, '{L:phpPgAdmin}', '/phpPgAdmin/index.php', 1, 'formUsername', 'formPassword', 1, 1, 1, 1, '<input type=\"hidden\" name=\"formLanguage\" value=\"english\">\r\n<input type=\"hidden\" name=\"formServer\" value=\"0\">')";
		mysql_query($SQL);
		$SQL = "INSERT INTO `links` VALUES (3, '{L:WebMail}', '/webmail/', 0, NULL, NULL, 1, 1, 1, 1, NULL)";
		mysql_query($SQL);
		break;
	case 'disable':
		break;
	case 'hook':
		register_hook('web:menu', 'external_links_add_menu');
		register_hook('web:lang', 'external_links_add_lang');
		register_hook('web:server:newaccount:table', 'external_links_reseller_settings');
		register_hook('web:reseller:resellerset:table', 'external_links_reseller_settings');
		register_hook('web:reseller:resellerinfo:table', 'external_links_get_infotable');
		register_hook('web:reseller:newdomain:table', 'external_links_domain_settings');
		register_hook('fetchdata:reseller:external_links', 'external_links_fetch');
		register_hook('fetchdata:reseller:*', 'external_links_fetch');
		register_hook('web:reseller:create', 'external_links_set');
		register_hook('web:reseller:update', 'external_links_set');
		register_hook('web:reseller:update:check', 'external_links_check');

		register_hook('fetchdata:total:external_links', 'external_links_fetch_total');
		register_hook('fetchdata:total:*', 'external_links_fetch_total');
		register_hook('fetchdata:alloc:external_links', 'external_links_fetch_alloc');
		register_hook('fetchdata:alloc:*', 'external_links_fetch_alloc');

		register_hook('web:domain:domainset:table', 'external_links_domain_settings');
		register_hook('web:domain:domaininfo:table', 'external_links_get_infotable');
		register_hook('fetchdata:domain:external_links', 'external_links_fetch');
		register_hook('fetchdata:domain:*', 'external_links_fetch');
		register_hook('web:domain:create', 'external_links_set');
		register_hook('web:domain:create:check', 'external_links_domain_check');
		register_hook('web:domain:update', 'external_links_set');
		register_hook('web:domain:update:check', 'external_links_domain_check');
		break;
}
?>